﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <meta charset="utf-8" />
    <!--引入插件-->
    <script type="text/javascript" src="avalidate-v2.0.0 beta.js"></script>
</head>
<body>
    <form id="frm">
        <h3 data-rule="*">必须输入3到6个字符：data-rule="a3-6"，如果添加了data-haved="true"之后，就不执行为空验证了，只有填写值的时候才执行验证</h3>
        <div>
            姓名：   <input type="text" data-rule="(/\d{2,3}/)or(zh)" data-nullmsg="2到3位数字或者中文" data-errmsg="您输入的不是2到3位的数字或者中文" data-sucmsg="" data-haved="true" />
        </div>
        <div>
            姓名2：   <input type="text" data-rule="*" data-nullmsg="姓名不能为空" data-errmsg="必须是3到6个字符" data-sucmsg="" data-haved="true" />
        </div>
        <br />
        <br />
        <input type="button" id="btn" value="提交" />
    </form>
    <script type="text/javascript">
        V.init({
            area: "#frm",
            btn: "#btn",
            before: function (form) {
            },
            success: function (form, formData) {
                alert("验证成功了");
            },
            error: function (form, errorElement, status) { },
            complete: function (form, status) {
            }
        });
    </script>
</body>
</html>
